<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWorkflowV2OrderLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('workflow_v2_order_logs', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('workflowOrderId')->default(0)->comment('workflow_v2_orders.id');
            $table->unsignedInteger('workflowOrderNodeId')->default(0)->comment('workflow_v2_order_nodes.id');
            $table->string('nodeName', 32)->default('')->comment('节点名称');
            $table->unsignedInteger('handlerUid')->default(0)->comment('处理人');
            $table->string('handlerName', 32)->default('')->comment('处理人显示名称');
            $table->tinyInteger('audit')->default(0)->comment('审核结果 1通过 2驳回');
            $table->unsignedInteger('rejectNodeId')->default(0)->comment('驳回，回退到的节点id');
            $table->tinyInteger('status')->default(0)->comment('0待完成 1完成');
            $table->string('content', 512)->default('')->comment('日志内容');
            $table->json('imgFiles')->nullable()->comment('图片文件');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->tinyInteger('isDeleted')->default(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '工作流 - 订单日志';

            $table->index('workflowOrderId', 'idx_workflowOrderId');
            $table->index('handlerUid', 'idx_handlerUid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('workflow_v2_order_logs');
    }
}
